package com.color.utils;

public class ObjectUtils {
	
	/**
	 * Object 转 String
	 * @param obj
	 * @return
	 */
	public static String convertString(Object obj){
		
		String str = "";
		
		if(obj != null){
			str = String.valueOf(obj);
		}
		
		return str;
	}
	
	
	/**
	 * Object 转 int
	 * @param obj
	 * @return
	 */
	public static int convertInt(Object obj){
		
		int iRet = 0;
		
		if(obj != null){
			iRet = Integer.parseInt(String.valueOf(obj));
		}
		
		return iRet;
	}
	
	/**
	 * String 转 Int
	 * @param str
	 * @return
	 */
	public static int stringToInt(String str){
		return (str == null || "".equals(str))?0:Integer.parseInt(str);
	}
	
	/**
	 * Object 转 boolean
	 * @param obj
	 * @return
	 */
	public static boolean convertBool(Object obj){
		boolean bRet = false;
		
		if(obj != null){
			bRet = Boolean.parseBoolean(String.valueOf(obj));
		}
		
		return bRet;
	}
}
